import os.path

print("获取文件的绝对路径", os.path.abspath("ospath模块的演示.py"))
print("获取文件的是否有效", os.path.isfile("ospath模块的演示.py"))  # True
print("获取路径是否有效", os.path.isdir('/home/deepin23/PycharmProjects/python_learn'))  # True
print("获取路径是否有效", os.path.isdir('/home/deepin23/PycharmProjects/python_learn2'))  # False
print("获取文件名称",
      os.path.basename('/home/deepin23/PycharmProjects/python_learn/os/os模块中常见的操作/ospath模块的演示.py'))
print("获取文件的路径",
      os.path.dirname('/home/deepin23/PycharmProjects/python_learn/os/os模块中常见的操作/ospath模块的演示.py'))
print("获取文件的父路径2", os.path.dirname('/home/deepin23/PycharmProjects/python_learn/os/os模块中常见的操作'))

print("拼接路径", os.path.join("/home/deepin23/", "a.txt"))
print("获取文件名称和后缀",
      os.path.splitext("/home/deepin23/PycharmProjects/python_learn/os/os模块中常见的操作/ospath模块的演示.py"))
print("路径是否存在", os.path.exists("/home/deepin23/"))
print("路径是否存在", os.path.exists("/home/deepin24"))
print("文件是否存在",
      os.path.exists("/home/deepin23/PycharmProjects/python_learn/os/os模块中常见的操作/ospath模块的演示.py"))
